#version 300 es

layout(location=0)in vec4 vertexPosition;
uniform float width;
uniform float height;

/**
* 获取正交投影矩阵
*/
mat4 getOrthMatrix(float width, float height){
    float ratio = width>height?width/height:height/width;
    if (width>height){ //横屏
        return mat4(
        1.0/ratio, 0.0, 0.0, 0.0,
        0.0, 1.0, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0,
        0.0, 0.0, 0.0, 1.0
        );
    } else { //竖屏
        return mat4(
        1.0, 0.0, 0.0, 0.0,
        0.0, 1.0/ratio, 0.0, 0.0,
        0.0, 0.0, 1.0, 0.0,
        0.0, 0.0, 0.0, 1.0
        );
    }
}

void main() {
    mat4 orthMatrix=getOrthMatrix(width, height);
    gl_Position=orthMatrix*vertexPosition;
}
